<template>
	<om-addpage style="padding-top: 35px;" :busCode="busCode" :menuName="menuName" @formSubmit="formSubmit" :showHistoryBtn="true">
		<om-autoform ref="autoform" :initConfigData="mainConfigData" :initValue="initValue"></om-autoform>
	</om-addpage>
</template>
<script>
	import {
		hasEditor,
		buildFormData,
		formValidation,
		changeEditor,
		formShowLoading,
		configFormEditor,
		getWorkCacheKey,
		changeConfigAttr,
		configSelectData,
		formModelLoad,
		getFormFields,
		getEditor,
		getEditorTitle,
		insertAfterEditor,
		insertEditors
	} from '@/static/js/formUtil.js';
	import dateTimePicker from '@/static/js/dateTimePicker.js';
	import urlUtil from '@/static/js/urlUtil.js';
	import { mapState } from 'pinia';
	import {useLoginUserStore} from '@/stores/login-user.js';
	import moment from '@/static/js/moment.js'
	import { getUrl, confirmModal, ptFloat, minusF } from '@/static/js/common.js';
export default {
	provide() {
		return {
			formPage: this
		};
	},
	data() {
		return buildFormData({
			initValue: {
				parentOthers:"",
				currentOthers:"",
				fileStr:[]
			},
			infonameCacheKey: 'hr-u-entry-infoname-cache',
			areaCacheKey: 'hr-u-entry-area-cache',
			parentAddressCacheKey:'hr-u-entry-parentAddress-cache',
			nationCacheKey:'hr-u-entry-nation-cache',
			currentAddressCacheKey:'hr-u-entry-currentAddress-cache',
			refereeCacheKey:'hr-u-entry-referee-cache',
			userNamesCacheKey:'hr-u-entry-userNames-cache',
			posCacheKey:'hr-u-entry-pos-cache',
			instCacheKey:'hr-u-entry-inst-cache',
			userData:'',
			remarkList:[]
		})
	},
	computed: {
		...mapState(useLoginUserStore, ['userName', 'userId','areaCode','areaName'])
	},
	methods: {
		verifyHandleStr(){
			let _that = this
			if(!_that.$refs.autoform.formdata.posId){
				let title  = _that.$refs.autoform.getEditorTitle("title16","posId")
				_that.om.toast('请先选择'+title)
				return false
			}else{
				return true
			}
		},
		getPosInfo(posId){
			let _that = this
			_that.om.request(
				"teRegister/getPosInfo",
				{
					posId:posId
				}
			).then(res=>{
				_that.$refs.autoform.formdata.parentUserName = res.value.parentUserName
				_that.$refs.autoform.formdata.classesName = res.value.classesName
				_that.$refs.autoform.formdata.salaryAccountingGroup = res.value.salaryAccountingGroup
			})
		},
		onSelectCurrentPlace(item){
			let _that = this
			_that.$refs.autoform.formdata.currentPlaceId = item.id
			_that.$refs.autoform.formdata.currentPlaceName = item.fullName
		},
		onSelectParentPlace(item){
			let _that = this
			_that.$refs.autoform.formdata.parentPlaceId = item.id
			_that.$refs.autoform.formdata.parentPlaceName = item.fullName
		},
		clearEntryDate(){
			let _that = this
			_that.$refs.autoform.clear("title17","entryDate")
			_that.$refs.autoform.clear("title17","probationMonthNum")
			_that.$refs.autoform.clear("title17","probation")
			_that.$refs.autoform.clear("title17","probationDate")
		},
		clearProbation(){
			let _that = this
			_that.$refs.autoform.clear("title17","probationMonthNum")
			_that.$refs.autoform.clear("title17","probation")
			_that.$refs.autoform.clear("title17","probationDate")
		},
		clearProbationDate(){
			let _that = this
			_that.$refs.autoform.clear("title17","probationMonthNum")
			_that.$refs.autoform.clear("title17","probation")
			_that.$refs.autoform.clear("title17","probationDate")
		},
		onInputProbationMonth(val){
			let _that = this
			if(val){
				let num = Math.round(Number(val))
					let date = ''
				let days = ''
				if(_that.$refs.autoform.formdata.entryDate){
					date = moment(_that.$refs.autoform.formdata.entryDate).add(num, 'M').format('YYYY-MM-DD');
					days = moment(date).diff(moment(_that.$refs.autoform.formdata.entryDate),'day')
				}else{
					let title = _that.$refs.autoform.getEditorTitle("title17","entryDate")
					_that.om.toast('请选择'+title)
					_that.$refs.autoform.clear("title17","probationMonthNum")
					return
				}
				_that.$refs.autoform.formdata.probationMonthNum = num
				_that.$refs.autoform.formdata.probationDate = date
				_that.$refs.autoform.formdata.probation = days
			}
		},
		getSalaryList1(posId){
			let _that = this
			_that.om.request(
				"tempInstAdjust/getSalaryList1",
				{
					posId: posId,
					busCode: _that.busCode
				}
			).then(res=>{
				for(let item of res.value){
					if(item.salaryName != 'salary1' && item.salaryName != 'salary2' && item.salaryName != 'salary3' && item.salaryName != 'salary4'){
						item.showSubTitle2 = false
					}
				}
				_that.subEditorObj["title_salary"].workList = res.value
			})
		},
		getAdressByIdCard(val){
			let _that = this
			_that.om.request(
				'tpiRegister/getAddressInfoByIdCard',
				{
					idCard:val,
					orgId:_that.orgId
				},
				'post'
			).then(res=>{
				if(res.value){
				_that.$refs.autoform.formdata.parentPlaceId = res.value.parentPlaceId
				_that.$refs.autoform.formdata.registerplace= res.value.parentPlaceName
				_that.$refs.autoform.formdata.registerCategoryId = res.value.registerCategoryId
				_that.$refs.autoform.formdata.registerCategoryName = res.value.registerCategoryName
				_that.$refs.autoform.initSelectIndex('title1','registerCategoryId')
				}
			})
		},
		getSexAndBirthDay(val){
			let _that = this
			_that.om.request(
				'tpiRegister/getSexBirth',
				{
					idcard:val,
					orgId:_that.orgId
				}
			).then(res=>{
				if(res.value){
					_that.$refs.autoform.formdata.infosex = res.value[0]=='M'?'男':'女'
					_that.$refs.autoform.formdata.infobirthday = moment(res.value[1]).format('YYYY-MM-DD')
					_that.$refs.autoform.formdata.birthplace = res.value[2]
				}
			})
		},
		onInputIdCard(val){
			this.getAdressByIdCard(val)
			this.getSexAndBirthDay(val)
		},
		formSubmit() {
			// console.log(this.formdata)
			if(this.$refs.autoform.hasEditor('title9',"provideAccommodationStr")){
				if(this.$refs.autoform.formdata.provideAccommodationStr){
					this.$set(this.formdata,"provideAccommodation",true)
				}
			}
			if(this.$refs.autoform.hasEditor('title9',"socialSecurityStr")){
				if(this.$refs.autoform.formdata.socialSecurityStr){
					this.$set(this.formdata,"socialSecurity",true)
				}
			}
			if(this.$refs.autoform.hasEditor('title13',"physicalExaminationStr")){
				if(this.$refs.autoform.formdata.physicalExaminationStr){
					this.$set(this.formdata,"physicalExamination",true)
				}
			}
			if(this.$refs.autoform.hasEditor('title13',"familyMembersInCurrentPlaceStr")){
				if(this.$refs.autoform.formdata.familyMembersInCurrentPlaceStr){
					this.$set(this.formdata,"familyMembersInCurrentPlace",true)
				}
			}
			if(this.$refs.autoform.hasEditor('title13',"myopiaStr")){
				if(this.$refs.autoform.formdata.myopiaStr){
					this.$set(this.formdata,"myopia",true)
				}
			}
			let remarkStr = []
			for(let i in this.$refs.autoform.formdata){
				if(this.remarkList.includes(i) && this.$refs.autoform.formdata[i]){
					let obj = {
						yes:true,
						remarkId:i
					}
					remarkStr.push(obj)
				}
			}
			this.$set(this.$refs.autoform.formdata,'remarkStr',JSON.stringify(remarkStr) )
			if(this.$refs.autoform.hasEditor('title17',"probation")){
				if(!this.formdata.probation && !this.formdata.probationMonthNum){
					confirmModal(this,'提示信息',"试用期为空，是否继续保存？",()=>{
						if(this.checkedit){
							this.om.formSave('commonForm/doCheckOrApproveUpdate');
						}else{
							this.om.formSave('teRegister/addTeRegister');
						}
					},()=>{
						return
					})
				}else{
					if(this.checkedit){
						this.om.formSave('commonForm/doCheckOrApproveUpdate');
					}else{
						this.om.formSave('teRegister/addTeRegister');
					}
				}
			}else{
				if(this.checkedit){
					this.om.formSave('commonForm/doCheckOrApproveUpdate');
				}else{
					this.om.formSave('teRegister/addTeRegister');
				}
			}
		},
		onInputProbation(num){
			let dateNum = Math.round(Number(num))
			if(this.formdata.entryDate){
				var d1 = this.moment(this.formdata.entryDate)
				var probationDate = d1.add(num, "days").format("YYYY-MM-DD")
				this.$refs.autoform.formdata.probationDate = probationDate
			}else if(this.formdata.probationDate){
				var d2 = this.moment(this.formdata.probationDate)
				var entryDate = d2.subtract(num, "days").format("YYYY-MM-DD")
				this.$refs.autoform.formdata.entryDate = entryDate
			}else{
				let title = this.$refs.autoform.getEditorTitle("title17","entryDate")
				this.om.toast('请选择'+title)
				this.$refs.autoform.clear("title17","probation")
				return
			}
			this.$refs.autoform.formdata.probation = dateNum
			this.$refs.autoform.clear("title17","probationMonthNum")
		},
		onSelectAttStartDate(val){
			let _that = this
			if(_that.$refs.autoform.formdata.entryDate){
				let d1 = moment(_that.$refs.autoform.formdata.entryDate)
				let d2 = moment(val)
				let diff = d1.diff(d2)
				if(diff!=0){
					let title1 = _that.$refs.autoform.getEditorTitle("title17","entryDate")
					let title2 = _that.$refs.autoform.getEditorTitle("title17","attStartDate")
					confirmModal(_that,'提示信息',title1+'和'+title2+'在同一天，是否继续选择？',()=>{},()=>{
						_that.$refs.autoform.clear("title17","attStartDate")
					})
				}
			}
		},
		onSelectEntryDate(item){
			var nowDate = new Date();
			var specifiedDate = new Date(item);
			var currentDateStr = this.moment(nowDate).format("YYYY-MM-DD");
			var currentDate = new Date(currentDateStr);
			var specifiedDateStr = item;
			if(specifiedDate > currentDate){
				confirmModal(this,'提示信息','当前日期为'+ currentDateStr +'，选择的上岗日期'+ specifiedDateStr +' 迟于当前日期，确认要延迟上岗吗？',()=>{
					
				},()=>{
					this.$refs.autoform.clear("title17","entryDate")
				})
			}
			if(specifiedDate < currentDate){
				confirmModal(this,'提示信息','当前日期为'+ currentDateStr +'，选择的上岗日期'+ specifiedDateStr +' 早于当前日期，确认要提前上岗吗？',()=>{
					
				},()=>{
					this.$refs.autoform.clear("title17","entryDate")
				})
			}			                
			
			var d1 = this.moment(item)
			if(this.formdata.probationDate){
				var d2 = this.moment(this.formdata.probationDate)
				var diff = d2.diff(d1, 'days')
				this.$refs.autoform.formdata.probation = diff
			}else if(this.formdata.probation){
				var probationDate = d1.add(this.formdata.probation, "days").format("YYYY-MM-DD")
				this.$refs.autoform.formdata.probationDate = probationDate
			}
			this.$refs.autoform.clear("title17","probationMonthNum")
		},
		//计算试用期到期日
		onSelectProbationDate(item){
			var d2 = this.moment(item)
			if(this.formdata.entryDate){
				var d1 = this.moment(this.formdata.entryDate) 
				var diff = d2.diff(d1, 'days')
				this.$refs.autoform.formdata.probation = diff
			}else if(this.formdata.probation){
				var entryDate = d2.subtract(this.formdata.probation, "days").format("YYYY-MM-DD")
				this.$refs.autoform.formdata.entryDate = entryDate
			}else{
				let title = this.$refs.autoform.getEditorTitle("title17","entryDate")
				this.om.toast('请选择'+title)
				this.$refs.autoform.clear("title17","probationDate")
				return
			}
		},
		onSelectIdType(item){
			let _that = this
			//身份证
			if(item.code != "20038"){
				//加载性别
				urlUtil.promise(urlUtil.dictZeroComboboxUrl("23591"), function(d){
					_that.$refs.autoform.insertAfterEditor('title1','idCard',{
						"type": "selectbox",
						"title": "性别",
						"valueField": "infosexCode",
						"prompt":"请选择",
						"required":false,
						data:configSelectData(d, 'code', 'dicname')
					})
				})
			}else{
				_that.$refs.autoform.removeEditor('title1','infosexCode')
			}
		},
		getWorkParam(){
			return {projectId:this.formdata.projectId}
		},
		verifyPos(){
			if(!this.$refs.autoform.formdata.infoname){
				return "请先输入或选择姓名"
			}
			return true
		},
		verifyUser(d){
			let _that = this
			this.om.request('teRegister/verifyUser',{
				userName:d.username,
				mobile:d.mobile,
				editId:null
			}).then(res=>{
				if(res.succeed){
					if(res.value){
						_that.om.toast(res.value)
					}else{
						_that.loadUserData(d)
						_that.loadPosData(d)
						_that.getSubInfoFunc(d)
					}
				}else{
					_that.om.toast(res.msg)
				}
			})
		},
		loadPosData(userData,instId){
			let _that = this;
			_that.$refs.autoform.changeEditor('title16','posId','type','linkbox')
			_that.$refs.autoform.changeEditor('title16','posId',{
				link: '../../public/pageSearch/pageSearch',
				linkParam: {
					method :'post',
					other:JSON.stringify({
						userName: userData ? userData.username : "",
						mobile: userData ? userData.mobile : "",
						isleave: userData ? userData.isleave : null,
						instId: instId? instId:''
					}),
					initload: true,
					namefield: 'posName / instName',
					namesplit:' / ',
					extrafield:'interviewResult',
					searchfield:'q',
					url: "teRegister/getPosList",
					cachename: _that.posCacheKey,
					placeholder: '请输入岗位名称'
				}
			});
		},
		loadUserData(d){
			let _that = this;
			var formdata = _that.$refs.autoform.formdata;
			_that.userData = d
			formdata.username = d.username
			formdata.infosex = d.sexName
			if(d.edu){
				formdata.infoeducation = d.edu
			}
			formdata.infophone = d.mobile
			formdata.birthplace = d.birthPlace
			formdata.infoname = d.username
			if (d.isleave) {
				formdata.areaCode = d.areaCode||this.areaCode
				formdata.areaName = d.areaName||this.areaName
				formdata.idTypeId = d.idTypeId
				formdata.idTypeName = d.idTypeName
				formdata.idCard = d.idCard
				formdata.infobirthday = d.birthdate
				formdata.nationCode = d.naition
				formdata.naitionName = d.naitionName
				formdata.marriageCode = d.marriageCode
				formdata.marriageName = d.marriageName
				formdata.infophone = d.mobile
				formdata.politicalId = d.politicalId
				formdata.politicalName = d.politicalName
				if(d.foreignLanguageLevel){
					formdata.foreignLanguageLevel = d.foreignLanguageLevel
				}
				if(d.bloodTypeCode){
					formdata.bloodTypeCode = d.bloodTypeCode
				}
				if(d.bloodTypeName){
					formdata.bloodTypeName = d.bloodTypeName
				}
				formdata.parentPlaceId = d.parentPlaceId||d.parentCountyId
				formdata.parentPlaceName = d.parentPlaceName||d.parentCountyName
				formdata.currentPlaceId = d.currentPlaceId||d.currentCountyId
				formdata.currentPlaceName = d.currentPlaceName||d.currentCountyName
			} else {
				this.tcanUserInfoFunc(d);
			}
		},
		//应聘人员信息赋值
		tcanUserInfoFunc(userData){
			let _that = this
			this.om.request('tcandidate/getUserInfo',{
				userName:userData.username,
				mobile:userData.mobile
			}).then(res=>{
				if(res.succeed){
					if(res.value){
						var d = res.value
						var formdata = _that.$refs.autoform.formdata
						formdata.areaCode = d.areaCode || _that.areaCode
						formdata.areaName = d.areaName || _that.areaName
						formdata.idTypeId = d.idTypeId
						formdata.idTypeName = d.idTypeName
						formdata.idCard = d.idCard
						formdata.infobirthday = d.infobirthday
						let editor = _that.$refs.autoform.getEditor("title1","nationCode")
						_that.$refs.autoform.$set(_that.$refs.autoform.formdata,"nationCode",d.nationCode)
						_that.$refs.autoform.$set(_that.$refs.autoform.formdata,"nationName",d.nationName)
						formdata.marriageCode = d.marriageCode
						formdata.marriageName = d.marriageName
						formdata.infophone = d.infophone
						formdata.politicalId = d.politicalId
						formdata.politicalName = d.politicalName
						if(d.foreignLanguageLevel){
							formdata.foreignLanguageLevel = d.foreignLanguageLevel
						}
						if(d.bloodTypeCode){
							formdata.bloodTypeCode = d.bloodTypeCode
						}
						if(d.bloodTypeName){
							formdata.bloodTypeName = d.bloodTypeName
						}
						formdata.parentPlaceId = d.parentPlaceId || d.parentCountyId
						formdata.parentPlaceName = d.parentPlaceName || d.parentCountyName
						formdata.registerplace = d.parentPlaceName || d.parentCountyName
						formdata.currentPlaceId = d.currentPlaceId || d.currentCountyId
						formdata.currentPlaceName = d.currentPlaceName || d.currentCountyName
						formdata.hopeSalary = d.hopeSalary
						if(d.provideAccommodation){
							formdata.provideAccommodation = d.provideAccommodation
						}
						if(d.socialSecurity){
							formdata.socialSecurity = d.socialSecurity
						}
						formdata.otherRequire = d.otherRequire
						if(d.selfIntroduction){
							formdata.selfIntroduction = d.selfIntroduction
						}
						formdata.parentOthers = d.parentOthers
						formdata.currentOthers = d.currentOthers
						_that.$refs.autoform.initSelectIndex("title1","idTypeId")
						_that.$refs.autoform.initSelectIndex("title1","marriageCode")
						_that.$refs.autoform.initSelectIndex("title1","politicalId")
						_that.$refs.autoform.initSelectIndex("title1","currentStatusId")
						_that.$refs.autoform.initSelectIndex("title1","bloodTypeCode")
					}
				}else{
					_that.om.toast(res.msg)
				}
			})
		},
		getSubInfoFunc(userData){
			let _that = this
			this.om.request('teRegister/getSubInfo',{
				userName:userData.username,
				mobile:userData.mobile
			}).then(res=>{
				if(res.succeed){
					if(res.value){
						var d = res.value
						if(d.eduList){
							var sub = _that.subEditorObj['title3']
							if(sub){
								sub.workList = d.eduList
							}
						}
						if(d.workList){
							var sub = _that.subEditorObj['title5']
							if(sub){
								sub.workList = d.workList
							}
						}else{
							var sub = _that.subEditorObj['title5']
							sub.workList = new Array()
						}
						if(d.familyList){
							var sub = _that.subEditorObj['title7']
							if(sub){
								sub.workList = d.familyList
							}
						}
					}
				}else{
					_that.om.toast(res.msg)
				}
			})
		},
		//个人资料赋值
		getFileListFunc(userData){
			let _that = this
			this.om.request('teRegister/getFileList',{
				userName:userData.username,
				mobile:userData.mobile
			}).then(res=>{
				if(res.succeed){
					if(res.value && res.value.length){
						var sub = _that.subEditorObj['title31']
						if(sub){
							sub.workList = res.value
						}
					}
				}else{
					_that.om.toast(res.msg)
				}
			})
		},
		onSelectPos(item) {
			let _that = this;
			var ajaxArr = [
				{
					url:'teRegister/getReasonList1',//事由
					param:{
						posId:item.posId
					}
				},
				{
					url:'teRegister/getType'//任职方式
				},
				urlUtil.dictZeroComboboxUrl("38001"),//合同类型
				{
					url:'trecruitAgencyInterviewEvaluate/getInfoByMenu',//上岗事由
					param:{
						posId:item.posId
					}
				},
				{
					url:'teRegister/getEmpByPosId',//根据岗位找现任职的人员
					param:{
						posId:item.posId
					}
				},
			];
			var hasTitle27 = this.$refs.autoform.hasGroupKey("title27");
			if(hasTitle27){
				this.$refs.autoform.changeEditor("title27","userIds",{
					linkParam:{
						other:JSON.stringify({
							formCode:this.busCode
						}),
						initload: true,
						namefield: 'text',
						url: "trecruitAgencyInterviewEvaluate/getUser",
						cachename: _that.userNamesCacheKey,
						placeholder: '请输入姓名'
					}
				})
			}
			urlUtil.promiseAll(ajaxArr, function(res) {
				_that.$refs.autoform.changeEditor('title17', 'reasonId', 'data', configSelectData(res[0], 'id', 'dicname'));
				_that.$refs.autoform.initSelectIndex('title17','reasonId')
				_that.$refs.autoform.changeEditor('title17', 'workTypeCode', 'data', configSelectData(res[1], 'code', 'dicname'));
				_that.$refs.autoform.initSelectIndex('title17', 'workTypeCode')
				_that.$refs.autoform.changeEditor('title34', 'contractTypeCode', 'data', configSelectData(res[2], 'code', 'dicname'));
				_that.$refs.autoform.initSelectIndex('title34', 'contractTypeCode')
				if(res[3].succeed) {
					var obj = res[3].value
					if(obj.interviewCatCode){
						_that.$refs.autoform.formdata.interviewCatCode = obj.interviewCatCode
					}
					if(obj.interviewCatName){
						_that.$refs.autoform.formdata.interviewCatName = obj.interviewCatName
					}
					if(obj.interviewCatCode == '38201'){//直接上级岗位参与面试
						_that.$refs.autoform.formdata.parentUserId = obj.parentUserId
						_that.$refs.autoform.formdata.parentUserName = obj.parentUserName
						_that.$refs.autoform.formdata.parentPosId = obj.parentPosId
						_that.$refs.autoform.formdata.parentPosName = obj.parentPosName
						_that.$refs.autoform.changeEditor('title25', 'parentPosId', {
							type:'labelbox',
							prompt:'',
							data: []
						});
					} else {
						_that.$refs.autoform.changeEditor('title25', 'parentPosId', {
							type:'selectbox',
							prompt:'请选择',
							data: configSelectData([obj], 'parentPosId', 'parentPosName')
						});
						_that.$refs.autoform.initSelectIndex('title25', 'parentPosId')
					}
				}
				_that.$refs.autoform.changeEditor('title17', 'replaceUserId', 'data', configSelectData(res[4], 'userId', 'userName'));
				_that.$refs.autoform.initSelectIndex('title17', 'replaceUserId')
			})
		},
		onSelectParentPos(item){
			this.$refs.autoform.formdata.parentUserId = item.parentUserId
			this.$refs.autoform.formdata.parentUserName = item.parentUserName
		},
		clearParentPos(){
			this.$refs.autoform.clear('title25','parentPosId')
			this.$refs.autoform.clear('title25','parentUserId')
		},
		onSelectReason(item){
			let _that = this;
			_that.om.request(
				'teRegister/getEffectWay',
				{
					posId:_that.formdata.posId,
					reasonId:item.id
				}
			).then(res=>{
				_that.$refs.autoform.changeEditor('title17', 'effectDateWayCode', 'data', configSelectData(res, 'code', 'dicname'));
				_that.$refs.autoform.initSelectIndex('title17', 'effectDateWayCode')
			})
			//人员调整
			if(item.code+'' == "38944"){
				_that.om.request(
					'teRegister/getEmpByPosId',
					{
						posId:_that.$refs.autoform.formdata.posId
					}
				).then(res=>{
					_that.$refs.autoform.changeEditor('title17', 'replaceUserId', {
						type:'selectbox',
						data:configSelectData(res,'userId', 'userName'),
						prompt:'请选择',
						required:true
					});
				})
			}else{
				_that.$refs.autoform.changeEditor('title17', 'replaceUserId', {
					type: 'labelbox',
					required:false
				});
				_that.$refs.autoform.clear('title17', 'replaceUserId')
			}
		},
		verifyEffectDateWay(){
			if(!_that.formdata.reasonId){
				return "请先选择事由"
			}
			return true
		},
		getInterviewParam(){
			var editor = this.subEditorObj["title29"];
			if(editor){
				if(editor.workList.length){
					return {listStr:editor.workList.map(e=>e.interviewElementId).join(",")}
				}
			}
			return {listStr:""}
		},
		getHandleParam(index){
			var obj = {
				
			}
			var editor = this.subEditorObj['title37']
			if(editor && editor.workList.length){
				obj.itemIdsStr = editor.workList.filter((e,ind)=>{
					return ind != index
				}).map(e=>e.itemId).join(",")
			}
			return obj
		},
		initLoad(options) {
			let _that = this;
			var ajaxArr = [
				urlUtil.zposUrl(options.code), //制表岗位
				urlUtil.sysdictComboboxUrl('20007'), //身份证件类别
				urlUtil.sysdictComboboxUrl('20010'),//政治面貌
				urlUtil.dictZeroComboboxUrl('23594'), //婚姻状况
				urlUtil.sysdictComboboxUrl('23586'),//目前状态
				urlUtil.sysdictComboboxUrl('23590'),//招聘途径
				urlUtil.dictZeroComboboxUrl('37381'),//血型
				urlUtil.sysdictComboboxUrl('23645'),//薪资档级
				{
					url:"temployee/getRoleCategoryList", //角色类别
				},
				urlUtil.dictZeroComboboxUrlByInCode('36924',"36925"),
				urlUtil.sysdictComboboxUrl('38644'),//户籍地类别
				{
					url:'teRegister/getEmpSupplyList'
				},//其他个人补充事项
				urlUtil.sysdictComboboxUrl('38782'),
				urlUtil.sysdictComboboxUrl('38787'),
				urlUtil.sysdictComboboxUrl('20404'),
				urlUtil.sysdictComboboxUrl('38791'),
				urlUtil.sysdictComboboxUrl('35872'),
				{
					url:'temployee/getMaxUserno'
				},//工号
				urlUtil.sysdictComboboxUrl('39009'),
				{
					url:'dictZero/getListByCode',
					param:{
						code:'37861'
					}
				},
				{
					url:'tsysdict/getListByCode',
					param:{
						code:'39665'
					}
				}, //户口
				{
					url:'tsysdict/getListByCode',
					param:{
						code:'39668'
					}
				}, //子女
				{
					url:'teRegister/getRemarkList'
				},//补充说明
				{
					url:"wxPosBusiAuth/defaultTableMaker",
					param: {
						code: options.code
					},
					method: "post"
				}
			];
			var fileId = options.fileId
			if(fileId){
				ajaxArr.push({
					url:'teRegister/getInfo',
					param:{
						id:fileId
					},
					method:"post" 
				})
			}
			formModelLoad(ajaxArr, function(res, mainData) {
				var defaultPosId = res[23].value.id || '';
				var defaultPosName = res[23].value.posName || '';
				var defaultInstId = res[23].value.instId || '';
				var defaultInstName = res[23].value.instName || '';
				changeEditor('topinfo', 'zposId', 'data', configSelectData(res[0], 'id', 'posname'), mainData);
				changeEditor('title1', 'idTypeId', 'data', configSelectData(res[1], 'id', 'dicname'), mainData);
				changeEditor('title1', 'politicalId', 'data', configSelectData(res[2], 'id', 'dicname'), mainData);
				changeEditor('title1', 'marriageCode', 'data', configSelectData(res[3], 'code', 'dicname'), mainData);
				changeEditor('title1', 'currentStatusId', 'data', configSelectData(res[4], 'id', 'dicname'), mainData);
				changeEditor('title13', 'recruitInfoApproachId', 'data', configSelectData(res[5], 'id', 'dicname'), mainData);
				changeEditor('title1', 'bloodTypeCode', 'data', configSelectData(res[6], 'code', 'dicname'), mainData);
				changeEditor('title12', 'salaryLevelId', 'data', configSelectData(res[7], 'id', 'dicname'), mainData);
				changeEditor('title13', 'roleCategoryId', 'data', configSelectData(res[8], 'id', 'dicname'), mainData);
				changeEditor('title13', 'physicalExaminationName', 'data', configSelectData(res[9], 'code', 'dicname'), mainData);
				changeEditor("title1","registerCategoryId",'data',configSelectData(res[10],'id','dicname'),mainData)
				changeEditor("title13","foreignLanguageId","data",configSelectData(res[12],'id','dicname'),mainData)
				changeEditor("title13","foreignLanguageLevelId","data",configSelectData(res[13],'id','dicname'),mainData)
				changeEditor("title13","computerAbilityId","data",configSelectData(res[14],'id','dicname'),mainData)
				changeEditor("title13","physicalConditionId","data",configSelectData(res[15],'id','dicname'),mainData)
				changeEditor("title13","salaryBankId","data",configSelectData(res[16],'id','dicname'),mainData)
				changeEditor("title34","contractTypeId","data",configSelectData(res[18],'id','dicname'),mainData)
				changeEditor("title17","budgetTypeCode","data",configSelectData(res[19],'code','dicname'),mainData)
				changeEditor("title1","householdId","data",configSelectData(res[20],'id','dicname'),mainData)
				changeEditor("title1","childrenId","data",configSelectData(res[21],'id','dicname'),mainData)
				
				let editors = []
				for(let item of res[11].value){
					let editor ={
						"type": "textarea",
						"title": item.itemName,
						"valueField":'remark'+item.itemId,
						"required":false,
						"prompt":"请点击输入",
						'placeholder':item.remarkPrompt
					}
					editors.push(editor)
				}
				insertEditors('title_empSupply',editors,mainData)
				let remarkEditors = []
				for(let item of res[22].value){
					_that.remarkList.push(item.id+'')
					let editor = {
						"type": "switchbox",
						"title": item.text,
						"valueField":item.id,
						"required":false,
						"prompt":"请点击输入",
					}
					remarkEditors.push(editor)
				}
				insertEditors('title_remarkInfo',remarkEditors,mainData)
				changeEditor('title1','infoname',{
					linkParam: {
						initload: true,
						namefield: 'username',
						notefield:'birthPlace',
						extrafield:'mobile',
						url: "teRegister/getUserList",
						cachename: _that.infonameCacheKey,
						placeholder: '请输入姓名、手机号、籍贯'
					}
				}, null, mainData);
				changeEditor('title1','areaCode',{//国家或地区选择
					link: '../../public/search/search',
					linkParam: {
						initload: true,
						namefield: 'dicname',
						url: "regions/getCountryList",
						cachename: _that.areaCacheKey,
						placeholder: '请输入名称'
					}
				}, null, mainData);
				changeEditor('title1','nationCode',{//民族选择
					link: '../../public/search/search',
					linkParam: {
						other:JSON.stringify({
							code:'20005'
						}),
						initload: true,
						namefield: 'dicname',
						url: urlUtil.dictZeroComboboxUrl().url,
						cachename: _that.nationCacheKey,
						placeholder: '请输入民族'
					}
				}, null, mainData);
				changeEditor('title1','parentPlaceId','type','areabox',mainData)
				changeEditor('title1','parentPlaceId',{//户籍
					link: '../../public/pageSearch/pageSearch',
					linkParam: {
						other:JSON.stringify({
							classifyCode:'35923'
						}),
						searchfield:'q',
						namefield: urlUtil.addressUrl().namefield,
						url: urlUtil.addressUrl().url,
						fullName:true,
						cachename: _that.parentAddressCacheKey,
						placeholder: '请输入地址'
					}
				}, null, mainData);
				insertAfterEditor('title1','parentPlaceId',{
					"type": "textarea",
					"title": "详细地址",
					"valueField": "parentOthers",
					"prompt":"请输入",
					"required":false,
				}, mainData)
				changeEditor('title1','currentPlaceId','type','areabox',mainData)
				changeEditor('title1','currentPlaceId',{//现居住地
					link: '../../public/pageSearch/pageSearch',
					linkParam: {
						other:JSON.stringify({
							classifyCode:'35923'
						}),
						searchfield:'q',
						fullName:true,
						namefield: urlUtil.addressUrl().namefield,
						url: urlUtil.addressUrl().url,
						cachename: _that.currentAddressCacheKey,
						placeholder: '请输入地址'
					}
				}, null, mainData);
				insertAfterEditor('title1','currentPlaceId',{
					"type": "textarea",
					"title": "详细地址",
					"valueField": "currentOthers",
					"prompt":"请输入",
					"required":false,
				}, mainData)
				changeEditor('title13','refereeId',{//推荐人
					link: '../../public/pageSearch/pageSearch',
					linkParam: {
						other:JSON.stringify({
							classifyCode:'35923'
						}),
						searchfield:'q',
						namefield: urlUtil.userPageUrl().namefield,
						url: 'temployee/getAutoCombobox1',
						cachename: _that.refereeCacheKey,
						placeholder: '请输入姓名'
					}
				}, null, mainData);
				changeEditor('title16','instId',{
					link: '../../public/search/search',
					linkParam: {
						namefield: 'text',
						searchfield:'q',
						initload:true,
						url: "tinstitution/getComboTree",
						cachename: _that.instCacheKey,
						placeholder: '请输入岗位名称',
					}
				}, null, mainData);
				changeEditor('title12','posId',{
					link: '../../public/pageSearch/pageSearch',
					linkParam: {
						method :'post',
						namefield: 'posName / instName',
						namesplit:' / ',
						extrafield:'interviewResult',
						searchfield:'q',
						url: "teRegister/getPosList",
						cachename: _that.posCacheKey,
						placeholder: '请输入岗位名称',
					}
				}, null, mainData);
				
				if (_that.subEditorObj['title3']) {
					let attr = {}
					var configData = _that.subConfigData['title3']
					if(hasEditor('title3','eduECode',configData)){
						let title = getEditorTitle('title3','eduECode',configData)
						attr.titleTemplate = '<%= eduEName %>'
					}
					if(hasEditor('title3','schoolE',configData)){
						let title = getEditorTitle('title3','schoolE',configData)
						attr.subtitle1Template = title+':<%= schoolE %>'
					}
					if(hasEditor('title3','studyDirectEName',configData)){
						let title = getEditorTitle('title3','studyDirectEName',configData)
						attr.subtitle2Template = title+':<%= studyDirectEName %>'
					}
					changeEditor("title3","eduStr",attr,mainData)
				}
				if (_that.subEditorObj['title5']) {
					let attr = {}
					var configData = _that.subConfigData['title5']
					if(hasEditor('title5','orgNameW',configData)){
						let title = getEditorTitle('title5','orgNameW',configData)
						attr.titleTemplate = '<%= orgNameW %>'
					}
					if(hasEditor('title5','dutyW',configData)){
						let title = getEditorTitle('title5','dutyW',configData)
						attr.subtitle1Template = title+':<%= dutyW %>'
					} 
					if(hasEditor('title5','majorYearW',configData)){
						let title = getEditorTitle('title5','majorYearW',configData)
						attr.subtitle2Template = title+':<%= majorYearW %>'
					}
					changeEditor("title5","workStr",attr,mainData)
				}
				// if (_that.subEditorObj['title7']) {
				// 	changeEditor('title7', 'familyStr', {
				// 		titleTemplate: '称谓：<%= appellationFName %>',
				// 		subtitle1Template: '姓名：<%= nameF %>',
				// 		subtitle2Template: '单位：<%= companyF %>',
				// 	}, 
				// 	null,
				// 	mainData);
				// }
				if (_that.subConfigData['title7']) {
					var configData = _that.subConfigData['title7']
					var attr = {}
					if(hasEditor('title7','appellationFCode',configData)){
						attr.titleTemplate = '<%= appellationFName %>'
					}
					if(hasEditor('title7','nameF',configData)){
						let title = getEditorTitle('title7','nameF',configData)
						attr.subtitle1Template = title+':<%= nameF %>'
					}
					if(hasEditor('title7','companyF',configData)){
						let title = getEditorTitle('title7','companyF',configData)
						attr.subtitle2Template = title+':<%= companyF %>'
					}
					changeEditor('title7', 'familyStr', attr, mainData);
				}
				if (_that.subEditorObj['title29']) {//面试评价要素
					changeEditor('title29', 'interviewStr', {
						getWorkParam:"getInterviewParam",
						titleTemplate: '<%= interviewElementName %>',
						subtitle1Template: '分值：<%= score %>',
					},null,mainData);
				}
				if (_that.subEditorObj['title31']) {
					changeEditor('title31', 'dataStr', {
							titleTemplate: '<%= dataName %>',
						},null,mainData);
				}
				if (_that.subEditorObj['title37']) {
					changeEditor('title37', 'handleStr', {
							getWorkParam:"getHandleParam",
							titleTemplate: '<%= itemName %>',
							subtitle1Template: '经办岗位：<%= handlePosName %>',
							subtitle2Template: '经办人：<%= handleUserName %>',
						}, null, mainData);
				}
				//劳动合同
				// changeEditor("title34", "uploadFileList", {
				// 	fileSaveNameField:'fileUrl',
				// 	uploadUrl: 'teRegister/uploadFile',
				// 	removeUrl: 'teRegister/removeInterimFile',
				// 	loadUrl: 'teRegister/getInterimFile',
				// }, null, mainData)
				if(_that.subEditorObj["title_pro"]){
					let att = {}
					let configData = _that.subConfigData["title_pro"]
					if(hasEditor("title_pro","proName",configData)){
						att.titleTemplate = '<%= proName %>'
					}
					if(hasEditor("title_pro","proGradeId",configData)){
						let title = getEditorTitle("title_pro","proGradeId",configData)
						att.subtitle1Template =title+':<%= proGradeName %>'
					}
					if(hasEditor("title_pro","issueDate",configData)){
						let title = getEditorTitle("title_pro","issueDate",configData)
						att.subtitle2Template = title+':<%= issueDate %>'
					}
					if(hasEditor("title_pro","certificateIssuingUnit",configData)){
						let title = getEditorTitle("title_pro","certificateIssuingUnit",configData)
						att.subtitle3Template =title+ ':<%= certificateIssuingUnit %>'
					}
					
					changeEditor("title_pro",'proStr',att,mainData)
				}
				if(_that.subEditorObj["title_salary"]){
					let att = {
						showAdd:false,
						showDel:false,
						getWorkParam:'getWorkParam2'
					}
					let configData = _that.subConfigData["title_salary"]
					if(hasEditor("title_salary","itemName",configData)){
						att.titleTemplate = "<%= itemName || '未填写'%>"
					}
					if(hasEditor("title_salary","beforeAdjustId",configData)){
						let title = getEditorTitle("title_salary","beforeAdjustId",configData)
						att.subtitle1Template = title + ":<%= beforeAdjust || '无'%>"
					}
					if(hasEditor("title_salary","afterAdjustId",configData)){
						let title = getEditorTitle("title_salary","afterAdjustId",configData)
						if(att.subtitle1Template){
							att.subtitle1Template = att.subtitle1Template +' | '+title + ":<%= afterAdjust || '未填写'%>"
						}else{
							att.subtitle1Template =title + ":<%= afterAdjust || '未填写'%>"
						}
					}
					if(hasEditor("title_salary","salary",configData)){
						let title = getEditorTitle("title_salary","salary",configData)
						att.subtitle2Template = title + ":<%= salary || '未填写'%>"
					}
					if(hasEditor("title_salary","remark",configData)){
						let title = getEditorTitle("title_salary","remark",configData)
						att.subtitle3Template = title + ":<%= remark || '未填写'%>"
					}
					changeEditor("title_salary","salaryStr",att,mainData)
				}
				var avatarEditor = {
					"type": "avatarbox",
					"title": "个人头像",
					"valueField": "fileStr",
					"uploadUrl":"uploadFileData/uploadInterimFile.do",
					formData:{
						key:30
					}
				}
				var avatarList = []
				if(fileId){
					if(res[24].value.uploadFileData && res[24].value.uploadFileData.id) {
						avatarList = [_that.om.getUrl("uploadFileData/getFile.do?key=30&fileId=" + res[24].value.uploadFileData.id)]
						_that.$refs.autoform.$set(_that.$refs.autoform.formdata, 'fileStr', JSON.stringify(res[24].value.uploadFileData))
						_that.$set(_that.formdata, 'fileStr', JSON.stringify(res[24].value.uploadFileData))
					}
					var fieldArr = getFormFields(mainData) 
					fieldArr.push("id","reasonCode")
					//主表赋值
					for(var i in res[24].value.teRegister){
						if(fieldArr.includes(i)){
							_that.$refs.autoform.$set(_that.$refs.autoform.formdata, i, res[24].value.teRegister[i])
							_that.$set(_that.formdata, i, res[24].value.teRegister[i])
						}
					}
					_that.userData = res[24].value.userData
					if(_that.$refs.autoform.formdata.instId){
						changeEditor('title16','posId','type','linkbox',mainData)
						changeEditor('title16','posId',{
							link: '../../public/pageSearch/pageSearch',
							linkParam: {
								method :'post',
								other:JSON.stringify({
									userName: _that.userData ? _that.userData.username : "",
									mobile: _that.userData ? _that.userData.mobile : "",
									isleave: _that.userData ? _that.userData.isleave : null,
									instId: _that.$refs.autoform.formdata.instId
								}),
								initload: true,
								namefield: 'posName / instName',
								namesplit:' / ',
								extrafield:'interviewResult',
								searchfield:'q',
								url: "teRegister/getPosList",
								cachename: _that.posCacheKey,
								placeholder: '请输入岗位名称'
							}
						},null,mainData);
					}
					//教育经历
					if(_that.subEditorObj["title3"]){
						var eduList = _that._.cloneDeep(res[24].value.eduList)
						_that.subEditorObj["title3"].workList = eduList
						_that.$refs.autoform.$set(_that.$refs.autoform.formdata, "eduStr", JSON.stringify(eduList))
						_that.$set(_that.formdata, "eduStr", JSON.stringify(eduList))
						delete res[24].value.eduList
						//审核修改时用到
						if(_that.subEditorObj["title3"]){//配置子表的新增和删除
							changeEditor("title3", "eduStr", {
								showDel: !_that.checkedit,
								showAdd:!_that.checkedit
							}, mainData)
						}
					}
					//工作经历
					if(_that.subEditorObj["title3"]){
						var workList = _that._.cloneDeep(res[24].value.workList)
						_that.subEditorObj["title5"].workList = workList
						_that.$refs.autoform.$set(_that.$refs.autoform.formdata, "workStr", JSON.stringify(workList))
						_that.$set(_that.formdata, "workStr", JSON.stringify(workList))
						delete res[24].value.eduList
						
						//审核修改时用到
						if(_that.subEditorObj["title3"]){
						if(_that.subEditorObj["title5"]){//配置子表的新增和删除
							changeEditor("title5", "workStr", {
								showDel: !_that.checkedit,
								showAdd:!_that.checkedit
							}, mainData)
						}
					}
					//个人资料
					if(_that.subEditorObj["title3"]){
						var datas = _that._.cloneDeep(res[24].value.datas)
						if(datas){
							_that.subEditorObj["title31"].workList = datas
						}
						_that.$refs.autoform.$set(_that.$refs.autoform.formdata, "dataStr", JSON.stringify(datas))
						_that.$set(_that.formdata, "dataStr", JSON.stringify(datas))
						delete res[24].value.datas
						
						//审核修改时用到
						if(_that.subEditorObj["title31"]){//配置子表的新增和删除
							changeEditor("title31", "dataStr", {
								showDel: !_that.checkedit,
								showAdd:!_that.checkedit
							}, mainData)
						}
					}
					//家庭成员
					if(_that.subEditorObj["title3"]){
						var familyList = _that._.cloneDeep(res[24].value.familyList)
						_that.subEditorObj["title7"].workList = familyList
						_that.$refs.autoform.$set(_that.$refs.autoform.formdata, "familyStr", JSON.stringify(familyList))
						_that.$set(_that.formdata, "familyStr", JSON.stringify(familyList))
						delete res[24].value.familyList
						
						//审核修改时用到
						if(_that.subEditorObj["title7"]){//配置子表的新增和删除
							changeEditor("title7", "familyStr", {
								showDel: !_that.checkedit,
								showAdd:!_that.checkedit
							}, mainData)
						}
					}
					if(_that.subEditorObj["title_salary"]){
						_that.subEditorObj["title_salary"].workList = res[24].value.salaryList
						let dataList = _that._.cloneDeep(res[24].value.salaryList)
						for(let item of dataList){
							if(item.salaryName != 'salary1' && item.salaryName != 'salary2' && item.salaryName != 'salary3' && item.salaryName != 'salary4'){
								item.showSubTitle2 = false
							}
						}
						_that.subEditorObj["title_salary"].workList = dataList
						_that.$refs.autoform.$set(_that.$refs.autoform.formdata,"salaryStr",JSON.stringify(dataList))
						_that.$set(_that.formdata,"salaryStr",JSON.stringify(dataList))
					}
					if(_that.subEditorObj["title_pro"]){
						var proList = _that._.cloneDeep(res[24].value.proList)
						_that.subEditorObj["title_pro"].workList = proList
						_that.$refs.autoform.$set(_that.$refs.autoform.formdata, "proStr", JSON.stringify(proList))
						_that.$set(_that.formdata, "proStr", JSON.stringify(proList))
						delete res[24].value.proList
					}
					//入职办理事项
					if(_that.subEditorObj["title3"]){
						var handles = _that._.cloneDeep(res[24].value.handles)
						if(handles.length){
							_that.subEditorObj["title37"].workList = handles
						}
						_that.$refs.autoform.$set(_that.$refs.autoform.formdata, "handleStr", JSON.stringify(handles))
						_that.$set(_that.formdata, "handleStr", JSON.stringify(handles))
						delete res[24].value.handles
						
						//审核修改时用到
						if(_that.subEditorObj["title37"]){//配置子表的新增和删除
							changeEditor("title37", "handleStr", {
								showDel: !_that.checkedit,
								showAdd:!_that.checkedit
							}, mainData)
						}
					}
					for(let item of res[24].value.remarkList){
						_that.$refs.autoform.$set(_that.$refs.autoform.formdata,item.remarkId,item.yes)
						_that.$set(_that.formdata, item.remarkId,item.yes)
					}
					_that.$nextTick(function(){
						this.$nextTick(function(){
							// this.$refs.autoform.initSelectIndex('topinfo', 'zposId');
							if(!_that.$refs.autoform.formdata.zposId){
								_that.$refs.autoform.initSelectVal("topinfo","zposId")
							}
							this.$refs.autoform.initSelectIndex('title1','idTypeId');
							this.$refs.autoform.initSelectIndex('title1','politicalId');
							this.$refs.autoform.initSelectIndex('title1','marriageCode');
							this.$refs.autoform.initSelectIndex('title1','currentStatusId');
							this.$refs.autoform.initSelectIndex('title13','recruitInfoApproachId');
							this.$refs.autoform.initSelectIndex('title1','bloodTypeCode');
							this.$refs.autoform.initSelectIndex('title16','salaryLevelId');
							this.$refs.autoform.initSelectIndex("title13","roleCategoryId")
							this.$refs.autoform.initSelectIndex("title13","physicalExaminationName")
							this.$refs.autoform.initSelectIndex("title1","registerCategoryId")
							this.$refs.autoform.initSelectIndex("title34","contractTypeId")
							this.$refs.autoform.initSelectIndex("title17","budgetTypeCode")
							this.$refs.autoform.initSelectIndex("title13","foreignLanguageId")  
							this.$refs.autoform.initSelectIndex("title13","foreignLanguageLevelId")
							this.$refs.autoform.initSelectIndex("title13","computerAbilityId")
							this.$refs.autoform.initSelectIndex("title13","physicalConditionId")
							this.$refs.autoform.initSelectIndex("title13","salaryBankId")
							this.$refs.autoform.initSelectIndex("title1","householdId")
							this.$refs.autoform.initSelectIndex("title1","childrenId")
							
							if(this.$refs.autoform.formdata.posId){
								if(_that.subEditorObj["title_salary"]){
									let configData = _that.subConfigData["title_salary"]
									let editor = getEditor("title_salary","afterAdjustId",configData)
									if(editor.checkedit){
										if(!_that.subEditorObj["title_salary"].workList[0].afterAdjustId){
											_that.getSalaryList1(this.$refs.autoform.formdata.posId)
										}
									}
								}
								this.onSelectPos({
									posId:this.$refs.autoform.formdata.posId
								})
							}
							if(this.$refs.autoform.formdata.reasonId){
								this.onSelectReason({
									id:this.$refs.autoform.formdata.reasonId,
									code:this.$refs.autoform.formdata.reasonCode
								})
							}
						})
					})
				  }
				}else{
					_that.$nextTick(function(){
						this.$nextTick(function(){
							if(!_that.$refs.autoform.formdata.userno){
								_that.$refs.autoform.formdata.userno = res[17].value
							}
							if(!_that.$refs.autoform.formdata.entryDate){
								_that.$refs.autoform.formdata.entryDate = moment().format('YYYY-MM-DD')
							}
							if(hasEditor("title13","roleCategoryId",mainData)){
								if(!_that.$refs.autoform.formdata.roleCategoryId){
									_that.$refs.autoform.$set(_that.$refs.autoform.formdata,'roleCategoryId',res[8][0].id)
									_that.$refs.autoform.$set(_that.$refs.autoform.formdata,'roleCategoryName',res[8][0].dicname)
									_that.$set(_that.formdata,'roleCategoryId',res[8][0].id)
									_that.$set(_that.formdata,'roleCategoryName',res[8][0].dicname)
									_that.$refs.autoform.initSelectIndex("title13","roleCategoryId")
								}
							}
							
							
							if(!_that.$refs.autoform.formdata.zposId){
								_that.$refs.autoform.formdata.zposId = defaultPosId
								_that.$refs.autoform.formdata.zposName = defaultPosName
								_that.$refs.autoform.formdata.zinstId = defaultInstId
								_that.$refs.autoform.formdata.zinstName = defaultInstName
								_that.$nextTick(function() {
									_that.$refs.autoform.initSelectIndex('topinfo',"zposId")
								})
							}else{
								if(!_that.checkedit){
									_that.$refs.autoform.initSelectIndex('topinfo',"zposId")
								}
							}
						})
					})
				}
				avatarEditor['fileList'] = avatarList
				insertAfterEditor('title1','idTypeId',avatarEditor, mainData)
				
			},options);
		}
	},
	onLoad(options) {
		this.initLoad(options);
	},
	onUnload(){
		//#ifdef APP-PLUS
		let _that = this;
		if (_that.$refs.autoform) {
			for (var fieldId in _that.subEditorObj) {
				uni.removeStorage({
					key: getWorkCacheKey(fieldId)
				});
			}
		}
		//#endif
	},
	onShow() {
		let _that = this;
		if (_that.$refs.autoform) {
			for (var fieldId in _that.subEditorObj) {
				let editor = _that.subEditorObj[fieldId];
				uni.getStorage({
					key: getWorkCacheKey(fieldId),
					success: function(res) {
						editor.workList = res.data;
						uni.removeStorage({
							key: getWorkCacheKey(fieldId)
						});
					}
				});
			}
			uni.getStorage({
				key: _that.infonameCacheKey,
				success: function(res) {
					if (res.data) {
						let d = res.data;
						if(Object.prototype.toString.call(d) == "[object Object]"){
							_that.verifyUser(d)
						}else{
							_that.$refs.autoform.formdata.infoname = d
						}
						uni.removeStorage({
							key: _that.infonameCacheKey
						});
					}
				}
			});
			uni.getStorage({
				key: _that.areaCacheKey,
				success: function(res) {
					if (res.data) {
						let d = res.data;
						var formdata = _that.$refs.autoform.formdata;
						formdata.areaCode = d.code
						formdata.areaName = d.dicname
						uni.removeStorage({
							key: _that.areaCacheKey
						});
					}
				}
			});
			uni.getStorage({
				key: _that.posCacheKey,
				success: function(res) {
					if (res.data) {
						let d = res.data;
						var formdata = _that.$refs.autoform.formdata;
						formdata.posId = d.posId
						_that.getPosInfo(d.posId)
						formdata.posName = d.posName
						formdata.salaryWay = d.salaryWay
						formdata.posGrade = d.posGrade || ''
						if(d.salaryLevelId){
							formdata.salaryLevelId = d.salaryLevelId
						}
						if(d.salaryLevelName){
							formdata.salaryLevelName = d.salaryLevelName
						}
						if(d.gradeSalaryRange){
							formdata.gradeSalaryRange = d.gradeSalaryRange
						}
						formdata.instMainUserName = d.instMainUserName
						
						_that.onSelectPos(d)
						_that.getSalaryList1(d.posId)
						_that.$refs.autoform.clear("title17","replaceUserId")
						_that.$refs.autoform.clear("title17","reasonId")
						_that.$refs.autoform.clear("title17","budgetTypeCode")
						_that.$refs.autoform.clear("title17","effectDateWayCode")
						uni.removeStorage({
							key: _that.posCacheKey
						});
					}
				}
			});
			uni.getStorage({
				key: _that.nationCacheKey,
				success: function(res) {
					if (res.data) {
						let d = res.data; 
						var formdata = _that.$refs.autoform.formdata;
						formdata.nationCode = d.code
						formdata.nationName = d.dicname
						uni.removeStorage({
							key: _that.nationCacheKey
						});
					}
				}
			});
			uni.getStorage({
				key: _that.parentAddressCacheKey,
				success: function(res) {
					if (res.data) {
						let d = res.data;
						var formdata = _that.$refs.autoform.formdata;
						_that.$refs.autoform.$refs.areapop.close()
						formdata.parentPlaceId = d.id
						formdata.parentPlaceName = d.dicname
						uni.removeStorage({
							key: _that.parentAddressCacheKey
						});
					}
				}
			});
			uni.getStorage({
				key: _that.currentAddressCacheKey,
				success: function(res) {
					if (res.data) {
						let d = res.data;
						var formdata = _that.$refs.autoform.formdata;
						_that.$refs.autoform.$refs.areapop.close()
						formdata.currentPlaceId = d.id
						formdata.currentPlaceName = d.dicname
						uni.removeStorage({
							key: _that.currentAddressCacheKey
						});
					}
				}
			});
			uni.getStorage({
				key: _that.refereeCacheKey,
				success: function(res) {
					if (res.data) {
						let d = res.data;
						var formdata = _that.$refs.autoform.formdata;
						formdata.refereeId = d.id
						formdata.refereeName = d.userPosInstName
						formdata.refereeMobile = d.mobile
						uni.removeStorage({
							key: _that.refereeCacheKey
						});
					}
				}
			});
			uni.getStorage({
				key: _that.instCacheKey,
				success: function(res) {
					if (res.data) {
						let d = res.data;
						var formdata = _that.$refs.autoform.formdata;
						formdata.instId = d.id
						formdata.instName = d.text
						_that.om.request(
							"tinstitution/getInstInfo",
							{
								instId:d.id
							}
						).then(res=>{
							_that.$refs.autoform.formdata.instLevelId =  res.value.instcatId
							_that.$refs.autoform.formdata.instLevelName =  res.value.instcatName
						})
						_that.loadPosData(_that.userData,d.id)
						uni.removeStorage({
							key: _that.instCacheKey
						});
					}
				}
			});
			uni.getStorage({
				key: _that.userNamesCacheKey,
				success: function(res) {
					if (res.data) {
						let d = res.data;
						var formdata = _that.$refs.autoform.formdata;
						formdata.userIds = d.map(e => e.id).join(",")
						formdata.userNames = d.map(e => e.text).join(",");
						_that.$refs.autoform.changeEditor('title27','userIds',{
							initSelect:d
						})
						uni.removeStorage({
							key: _that.userNamesCacheKey
						});
					}
				}
			});
		}
	}
};
</script>
<style></style>
